import java.util.ArrayList;
import java.util.Scanner;

class Student{
    int id;
    int index;

    public Student(int id) {
        this.id = id;
    }

    public Student(int id, int index) {
        this.id = id;
        this.index = index;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }
}
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int count=sc.nextInt();
        if (count==1){
            System.out.println(1);
            System.out.println();
            return;
        }
        ArrayList<Student> list=new ArrayList();
        for (int i=0;i<count;i++){
            int id=sc.nextInt();
            if (i%2==0){
                list.add(new Student(id,1));
            }else {
                list.add(new Student(id,0));
            }
        }
        String l="";
        String o="";
        for (Student s:list){
            if (s.index==1){
                l+=s.id+" ";
            }else {
                o+=s.id+" ";
            }
        }
        System.out.println(l.substring(0,l.length()-1));
        System.out.println(o.substring(0,o.length()-1));
    }
}
